package com.zhx.sweet.aes;

import com.zhx.sweet.aes.inf.GetEncryptKey;
import com.zhx.sweet.common.properties.EncryptProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * describe: APP端获取加密key的操作
 *
 * @author zhanghaixuan
 * @date 2018/07/17
 **/
@Component
public class GetAesKey implements GetEncryptKey {
    @Autowired
    private EncryptProperties encryptProperties;

    @Override
    public String getEncryptKey() {
        //测试阶段
        return encryptProperties.getKey();

//        try{
//            OAuth2Authentication authentication = (OAuth2Authentication) SecurityContextHolder.getContext().getAuthentication();
//            String clientId = authentication.getOAuth2Request().getClientId();
//
//            return clientId;
//        }catch (Exception ex){
//            return encryptProperties.getKey();
//        }
    }
}
